07. Challenge 3

Functions

In this quiz, I want you to write a function called factorial that returns an int. A factorial is a mathematical operation designated by a ! operator and returns the product of a number and every whole number between it and 0. For example:

4! = 4 \cdot 3 \cdot 2 \cdot 1 = 24

You'll write your code within Factorial.cpp. Good luck!

Task List:

Task Feedback:

Cool! Test your code below!

Start Quiz:

#include "Factorial.h"

// Your code goes here! 
// See Factorial.h for your method's signature (eg, its args and return value).

/**
 * No need to change this file. This simply declares that Factorial returns 
 *   an int and takes an int as the sole argument.
 */

#ifndef FACTORIAL_H
#define FACTORIAL_H

int Factorial(int n);

#endif  // FACTORIAL_H
#include <iostream>
#include "Factorial.h"

int main() {
  // feel free to change this test case!
  int value = Factorial(6);
  std::cout << "6! should equal 720. Your Factorial method returned:" 
            << std::endl;
  std::cout << value << std::endl;
}